﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>管理登录 - 管理后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Font Awesome -->
    <link rel="stylesheet" href="/plugins/fontawesome-free/css/all.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- icheck bootstrap -->
    <link rel="stylesheet" href="/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
    <!-- SweetAlert2 -->
    <link rel="stylesheet" href="/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/css/adminlte.min.css">
    <!-- 自定义  style -->
    <link href="~/css/custom/global.css" rel="stylesheet" />


    <link href="~/img/fav.ico" rel="shortcut icon">

</head>
<body class="hold-transition login-page">
    <div class="login-box">
        <div class="login-logo">
            <a href="#"><b></b></a>
        </div>
        <!-- /.login-logo -->
        <div class="card">
            <div class="card-body login-card-body">
                <p class="login-box-msg">管理登录</p>
                <div class="input-group mb-3">
                    <input id="UserName" name="UserName" class="form-control" placeholder="用户名">
                    <div class="input-group-append">
                        <div class="input-group-text">
                            <span class="fas fa-user"></span>
                        </div>
                    </div>
                </div>
                <div class="input-group mb-3">
                    <input id="Password" name="Password" class="form-control" type="password" placeholder="密码">
                    <div class="input-group-append">
                        <div class="input-group-text">
                            <span class="fas fa-lock"></span>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-12">
                        <button id="btnLogin" type="button" class="btn btn-primary btn-block">登录</button>
                    </div>
                    <!-- /.col -->
                </div>
                <p class="mb-0">
                </p>
            </div>
            <!-- /.login-card-body -->
        </div>
    </div>
    <!-- /.login-box -->
    <!-- jQuery -->
    <script src="~/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="~/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- SweetAlert2 -->
    <script src="~/plugins/sweetalert2/sweetalert2.min.js"></script>
    <!-- AdminLTE App -->
    <script src="~/js/adminlte.min.js"></script>
    <!-- 自定义 GLOBAL JS -->
    <script src="~/js/custom/global.js"></script>
    <script type="text/javascript">
        $(function () {
            $(document).bind("keydown", function (e) {
                // 兼容FF和IE和Opera
                var theEvent = e || window.event;
                var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
                if (code == 13) {
                    //回车执行查询
                    $("#btnLogin").click();
                }
            });

            $("#btnLogin").click(function () {
                var um = $.trim($("#UserName").val());
                var pwd = $.trim($("#Password").val());
                if (um.length == 0) {
                    alert("请输入用户名");
                    return;
                }
                if (pwd.length == 0) {
                    alert("请输入密码");
                    return;
                }

                $("#btnLogin").attr("disabled", true).text("正在登录...");
                var json = { "UserName": um, "Password": pwd };
                AjaxPost("/Admin/Account/Login", JSON.stringify(json), function (result) {
                    if (result.code == 200) {
                        window.gp.user.Set({ UserName: result.data.name, Avatar: result.data.avatar });
                        window.location = "/Admin";
                    }
                }, function () {
                    $("#btnLogin").text("登录").attr("disabled", false);
                });
            });
        });
    </script>
</body>
</html>

